package com.songqintuan.common.dal.ibatis.baseservice;

import java.io.Serializable;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.songqintuan.common.bean.Page;
import com.songqintuan.common.dal.ibatis.basedao.IIbatisDao;

public class OperateServiceIbatisImp<T,PK extends Serializable> implements IOperateServiceIbatis<T, PK> {

	@SuppressWarnings("unused")
	private Logger logger = Logger.getLogger(this.getClass());
	
	private IIbatisDao<T,PK> realIbatisDao;
	
	
	public void setEntityClass(Class<T> entity) {
		realIbatisDao.setEntityClass(entity);
		
	}

	/* (non-Javadoc)
	 * @see com.szairport.blc.service.IOperateManager#setPKClass(java.lang.Class)
	 */
	public void setPKClass(Class<PK> pk) {
		this.realIbatisDao.setPKClass(pk);
	}
	public IIbatisDao<T, PK> getRealIbatisDao() {
		return realIbatisDao;
	}

	public void setRealIbatisDao(IIbatisDao<T, PK> realIbatisDao) {
		this.realIbatisDao = realIbatisDao;
	}

	public OperateServiceIbatisImp(){
		
	}

	public Integer count(String propertyName, Object propertyValue)
			throws SQLException, Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.count(propertyName, propertyValue);
	}

	public Integer countLikeByMap(String[] propertyNames,
			Object[] propertyValues) throws Exception, Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.countLikeByMap(propertyNames, propertyValues);
	}

	public int delete(T o) throws SQLException {
		// TODO Auto-generated method stub
		return realIbatisDao.delete(o);
	}

	public int deleteById(PK id) throws SQLException {
		// TODO Auto-generated method stub
		return realIbatisDao.deleteById(id);
	}

	public void deleteByIdsMap(List<PK> ids, String[] properties,
			Object[] propertyValues) throws Exception {
		// TODO Auto-generated method stub
		realIbatisDao.deleteByIdsMap(ids, properties, propertyValues);
	}

	public int deleteByMap(String[] properties, Object[] propertyValues)
			throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.deleteByMap(properties, propertyValues);
	}

	public List<T> find(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.find(map);
	}

	public List<T> findBy(String property, Object value) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.findBy(property, value);
	}

	public T findById(PK id) throws Exception, Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.findById(id);
	}

	public List<T> findByIds(List<PK> ids) throws Exception, Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.findByIds(ids);
	}

	public List<T> findByLike(String name, String value) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.findByLike(name, value);
	}

	public T findUniqueBy(String name, Object value) {
		// TODO Auto-generated method stub
		return realIbatisDao.findUniqueBy(name, value);
	}

	public T findUniqueByMap(Map<String, Object> map) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.findUniqueByMap(map);
	}

	public List<T> getAll() throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.getAll();
	}

	public void insert(T o) throws Exception {
		// TODO Auto-generated method stub
		
	}

	public Page<T, PK> pagedQuery(String sqlName,
			HashMap<String, Object> hashMap, Integer pageNo, Integer pageSize)
			throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.pagedQuery(sqlName, hashMap, pageNo, pageSize);
	}

	public Page<T, PK> pagedQuery(String sqlName, String[] properties,
			Object[] propertyValues, Integer pageNo, Integer pageSize)
			throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.pagedQuery(sqlName, properties, propertyValues, pageNo, pageSize);
	}

	public int update(T o) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.update(o);
	}

	public int update(PK id, String[] properties, Object[] propertyValues)
			throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.update(id, properties, propertyValues);
	}

	public int updateByIdsMap(List<PK> ids, String[] properties,
			Object[] propertyValues) throws Exception {
		// TODO Auto-generated method stub
		return realIbatisDao.updateByIdsMap(ids, properties, propertyValues);
	}
}
